package com.xiong.fan.proxy.custom;

import com.xiong.fan.proxy.jdk.ESQueryServiceImpl;
import com.xiong.fan.proxy.jdk.QueryService;

import java.lang.reflect.Method;

public class CustomQuery implements GPInvocationHandler {

    private QueryService target;

    public QueryService getInstance(QueryService target){
        this.target=target;
        return  (QueryService)GProxy.newProxyInstance(new GPClassLoader(), target.getClass().getInterfaces(),this);
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("before");
        method.invoke(this.target,args);
        System.out.println("after");
        return null;
    }
}
